package cn.wolfcode.wms.domain;


import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class Employee extends BaseDomain{


    private String name;

    private String password;

    private String email;

    private Integer age;

    private boolean admin ;

    private Department dept;

    private List<Role> roles = new ArrayList<>();


    public String getRoleNames(){

        if(this.admin){
            return "[超级管理员]";
        }

        List<Role> roles =this.getRoles();
        if(roles.size() == 0){

            return "[贫民]";
        }

        StringBuilder sb = new StringBuilder();
        sb.append("[");

        for (Role role : roles) {
            sb.append(role.getName()).append(",");
        }

        sb.deleteCharAt(sb.length()-1);
        sb.append("]");
        return sb.toString();
    }



}